<template>
  <div class="newArticle">
    <div class="title">
      <div style="color: black">最新文章</div>
      <div><a style="color: black" href="#/artilce/index">全部文章</a></div>
    </div>
    <div class="articleList">
      <div v-for="item in articleList" :key="item.id" class="items">
        <div class="articleImg">
          <img style="width: 100%" :src="item.cover" alt="">
        </div>
        <div style="color: black; margin-top: 10px">{{ item.title }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState, mapActions } from 'vuex'
export default {
  created() {
    this.getArticleList()
  },
  computed: {
    ...mapState({
      articleList: (state) => state.workbench.articleList
    })
  },
  methods: {
    ...mapActions({
      getArticleList: 'workbench/getArticleList'
    })
  }
}
</script>

<style lang="scss" scoped>
.newArticle {
  background-color: #fff;
  margin-top: 24px;
  .title {
    display: flex;
    padding: 24px;
    justify-content: space-between;
  }
  .articleList {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    padding: 20px 0 0 0;
    .items:hover {
      box-shadow: 0px 0px 3px 0px;
    }
    .items {
      width: 33.33%;
      display: flex;
      flex-direction: column;
      padding: 24px;
      border: 1px solid #eee;
      text-align: center;
      cursor: pointer;
      .articleImg {
        height: 140px;
        display: flex;
        overflow: hidden;
        align-items: center;
      }
    }
  }
}
</style>
